from core.support import set_cutscene
from core.item import Item
from core.action import Action

class ElevatorKeycard(Item):
    def __init__(self):
        Item.__init__(self, "elevator keycard")    # do basic initialization for every item
        
        # build list of actions
        self.add_action(UnlockElevator)
    
    def get_description(self):
        return "elevator keycard"

# define actions for this item

class UnlockElevator(Action):
    def __init__(self):
        Action.__init__(self, "unlock_Elevator")    # do basic initialization for every action
    
    # return description of action (used in label on webpage)
    def get_description(self):
        return "Unlock elevator"
    
    # return http method to use when user clicks on this action
    # use "get" if just moving to another room.  if changing something
    # like the state of an inventory item or room then use "post"
    def get_method(self):
        return "post"
    
    # only works in basement. add cutscene
    def do_action(self,game,room,request):
        if room.get_id() == 'elevator':
            if room.elevator_lock:
                set_cutscene("You swiped the keycard and gained access to the elevator leading to the rooftop.")
                room.elevator_lock = False
            else:
                set_cutscene("The elevator is already unlocked.")
        else:
            set_cutscene("There's no elevator here.")
        return